package ca.etsmtl.log720.tp3.dao;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class DossierDAOImpl implements DossierDAO {
    
    @Autowired   
    private SessionFactory sessionFactory;
    
    @Override
    public void addInfraction(Dossier dossier, Infraction infraction) {
        dossier.getInfractions().add(infraction);
        sessionFactory.getCurrentSession().save(dossier);
    }

    @Override
    public void addDossier(Dossier dossier) {
        sessionFactory.getCurrentSession().save(dossier);
    }

    @Override
    public List<Dossier> listDossier() {
        return sessionFactory.getCurrentSession().createQuery("from Dossier").list();
    }

}
